%% getHeartRateManually
%
% Prompts user to input heart rate manually
%
%% Synatax
%
% [ heartRate ] = getHeartRateManually ( dicomImg, inputAxes, instructionText )
%
% [ 45 ] = getHeartRateManually ( dicomImg, inputAxes, instructionText )
%
% [ 120 ] = getHeartRateManually ( dicomImg, inputAxes, instructionText )
%
%% Description
%
% This function prompts the user to view a clinical image (a dicom for
% example) and enter the heart rate information displayed on the image.
% Allowable values are numerics between 20 and 200.
%
%% Arguments
%* dicomImg                          - Double: An image containing heart
%                                              rate information
%
%* inputAxes                         - matlab.graphics.axis.Axes (Object): 
%                                      Axes parameters for the GUI
%
%* instructionText                   - matlab.ui.control.UIControl (Object): 
%                                      Text box parameters for the 
%
%% Returns
%
%* heartRate                         - Double: The user entered heart rate
%
%% Function Side Effects
%
%* A figure is displayed
%
%* The user is prompted to enter a heart rate in the console with a dialog
%  box
%
%* A warning message will be displayed if user entered heart rate value is 
%  not within 20 and 200
% 
%* A warning message will be displayed if user entered heart rate value is 
%  empty
%
%* A warning message will be displayed if user entered heart rate value is 
%  not numeric
%
%% Exceptions
%
%* N/A
%
%% See Also
% 
% getFlowHeartRate
%

function [ heartRate ] = getHeartRateManuallyGUI ( dicomImg, inputAxes, instructionText )
    
validHeartRate = 0;

% Verifies user is entering a legitimate value
while validHeartRate == 0
    
    axes(inputAxes)
    imshow(dicomImg);
    hold on
    
    set(instructionText, 'string', 'Please enter heart rate in bpm (20-200)');
    
    heartRateText = cell2mat(inputdlg(strcat('Please enter heart rate in beats per minute (20-200): '), ...
    'Enter Heart Rate.',[1 40],{'60'},'on'));
    
    if isempty(heartRateText) == 0
        
        heartRate = str2double(heartRateText);
        
    elseif isempty(heartRateText) == 1
        
        heartRate = '';
        
    end
    
    if isnan(heartRate)
        
        % Reset to allow for validateHeartRate to hold the error checking
        % logic
        heartRate = heartRateText;
        
    end
        
    validHeartRate = validateHeartRate(heartRate); 
    
end
    
end

